import { CouponPurpose } from "@/filters/data.ts";
import { getFiltersDictParaphrase } from "@/filters/utils.ts";
import { isGuoJinJieCustom } from "@/utils/customMall.ts";

export const getShowFormItem = (row: ObjValueAny) => {
    const {
        youHuiQuanJia,
        huHongYouXi,
        dingXiangFaQuan,
        saoMaFaQuan,
        youJiaQuanBao,
        youJiaFenLeiQuanBao,
        wenJuanDiaoCha,
        fuFeiHuiYuan,
        zhuCeSongHaoLi,
        huiYuanDengJiLi,
        qianDaoJiangLi,
        wanShanXinXiLi,
    } = getFiltersDictParaphrase(CouponPurpose());// 券用途

    // 显示 优惠券详情 关联
    const link: boolean = row.purpose === huHongYouXi || row.purpose === dingXiangFaQuan || row.purpose === youJiaQuanBao || row.purpose === wenJuanDiaoCha;
    // 显示 优惠券所属活动
    const campaigns: boolean = isGuoJinJieCustom() && !(row.purpose === youJiaQuanBao || row.purpose === wenJuanDiaoCha || row.purpose === youJiaFenLeiQuanBao);
    // 显示 会员领取权限
    const buyLimit: boolean = row.purpose === youHuiQuanJia;
    const buyLimitDetail: boolean = buyLimit || row.purpose === youJiaQuanBao || row.purpose === wenJuanDiaoCha;
    // 显示 是否限领
    const receiveRule: boolean = row.purpose == youHuiQuanJia || row.purpose == saoMaFaQuan;
    // 显示 自定义发券权限
    const sendShop: boolean = row.purpose === saoMaFaQuan;
    // 显示 发放方式
    const sendWay: boolean = row.purpose === youJiaFenLeiQuanBao || !(row.purpose === youJiaQuanBao || row.purpose === wenJuanDiaoCha);
    const sendWayDetail: boolean = row.purpose !== youJiaQuanBao || row.purpose === youJiaFenLeiQuanBao;
    // 显示 发放方式 只有持续发放
    const sustain: boolean = !(row.purpose === youHuiQuanJia || row.purpose === saoMaFaQuan);
    // 显示 预热时间
    const advanceNotice: boolean = row.purpose === youHuiQuanJia;

    return {
        link,
        campaigns,
        buyLimit,
        buyLimitDetail,
        receiveRule,
        sendWay,
        sendWayDetail,
        sendShop,
        sustain,
        advanceNotice,
    }
}